<template>
  <div>
    <el-drawer :visible.sync="dialogVisible" :direction="direction" size="700px" :before-close="handleClose">
      <div slot="title" class="title">{{ $t('dingDanXiangQing') }}</div>
      <div v-loading="loading" class="demo-drawer__content">
        <div v-if="orderDatalist" class="description">
          <div class="title">{{ $t('shouHuoXinXi') }}</div>
          <div class="acea-row">
            <div class="description-term">{{ $t('shouHuoRen') }}：{{ orderDatalist.receiveName }}</div>
            <div class="description-term">{{ $t('shouHuoDianHua') }}：{{ orderDatalist.receivePhone }}</div>
            <div class="description-term">{{ $t('shouHuoDiZhi') }}：{{ orderDatalist.formattedAddress }}</div>
          </div>

          <!-- <div v-for="(item, index) in orderDatalist.orderDetailList" :key="index" class="acea-row">
            <div class="description-term">{{ $t('shangPinMingCheng') }}：{{ item.productName }}</div>
            <div class="description-term">{{ $t('shangPinJiaGe') }}：{{ item.price }}</div>
            <div class="description-term">{{ $t('shangPinSku') }}：{{ item.skuCode }}</div>
            <div class="description-term">{{ $t('shangPinShuLiang') }}：{{ item.payNum }}</div>
            <div class="description-term">{{ $t('shangPinZhongLiang') }}：{{ item.weight }}</div>
            <div class="description-term">{{ $t('shangPinTiJi') }}：{{ item.volume }}</div>
            <div class="description-term">
              {{ $t('shangPinTuPian') }}：
              <div class="demo-image__preview mr10">
                <el-image :src="item.productImage" :preview-src-list="[item.productImage]" />
              </div>
            </div>
          </div> -->
          <el-divider />
          <div class="title">{{ $t('dingDanXinXi') }}</div>
          <div class="acea-row">
            <div class="description-term">{{ $t('halykDingDanHao') }}：{{ orderDatalist.haOrderCode }}</div>
            <div class="description-term">{{ $t('zhuDingDanHao') }}：{{ orderDatalist.orderCode }}</div>
            <div class="description-term">订单类型：{{ orderDatalist.orderTypeDesc }}</div>
            <div class="description-term" style="color: red">
              {{ $t('dingDanZhuangTai') }}：{{ orderDatalist.statusDesc }}
            </div>
            <div class="description-term">{{ $t('dingDanShangPinZhongShu') }}：{{ orderDatalist.countPlace }}</div>
            <div class="description-term">{{ $t('shangPinZongJia') }}：{{ orderDatalist.totalPrice }}</div>
            <div class="description-term">{{ $t('zhiFuYouFei') }}：{{ orderDatalist.postagePrice }}</div>
            <div class="description-term">{{ $t('xiaDanShiJian') }}：{{ orderDatalist.createTime }}</div>
            <div class="description-term">{{ $t('zhiFuFangShi') }}：{{ orderDatalist.paymentMode }}</div>
            <div class="description-term">{{ $t('quXiaoYuanYin') }}：{{ orderDatalist.cancellationReasonDesc }}</div>
            <div class="description-term">{{ $t('beiZhu') }}：{{ orderDatalist.comment }}</div>
            <div class="description-term">Yandex OTP码：{{ orderDatalist.endMerchantPassOtp }}</div>
          </div>
          <el-divider />
          <div class="title">{{ $t('shangPinXinXi') }}</div>
          <el-table :data="orderDatalist.orderDetailList" border>
            <el-table-column :label="$t('shangPinMingCheng')" prop="productName"></el-table-column>
            <el-table-column :label="$t('gongYingShang')" prop="merchantName"></el-table-column>
            <el-table-column :label="$t('zongJiaGe')" prop="totalPrice"></el-table-column>
            <el-table-column :label="$t('chanPinJiaGe')" prop="price"></el-table-column>
            <el-table-column :label="$t('skuShuLiang')" prop="payNum"></el-table-column>
            <el-table-column :label="$t('skuBianMa')" prop="skuCode"></el-table-column>
            <el-table-column :label="$t('shangPinWeiYiMa')" prop="skuOnlyCode"></el-table-column>
          </el-table>

          <template v-if="orderDatalist.beginTrackDetailList && orderDatalist.beginTrackDetailList.length > 0">
            <el-divider />
            <div class="title">{{ $t('touChengWuLiuXinXi') }}</div>
            <el-collapse v-model="activeNames">
              <el-collapse-item v-for="(mer,index) in orderDatalist.beginTrackDetailList" :key="index" :title="$t('shangHu')+'：'+mer.merName" :name="mer.merName">
                <div v-for="list in mer.trackDetailList" :key="list.merName">
                  <span>{{ $t('kuaiDiDanHao') }}：{{list.beginExpressNumber }}</span>
                  <el-timeline :reverse="reverse" style="margin-top: 20px;">
                  <el-timeline-item v-for="(item, i) in list.trackDetailList" :key="i">
                    <p class="time" v-text="item.date" />
                    <p class="content" v-text="item.status" />
                  </el-timeline-item>
                </el-timeline>
                </div>
              </el-collapse-item>
            </el-collapse>
          </template>

          <template v-if="orderDatalist.endTrackDetailList && orderDatalist.endTrackDetailList.length > 0">
            <el-divider />
            <div class="title">{{ $t('weiChengWuLiuXinXi') }}</div>
            <el-timeline :reverse="reverse">
              <el-timeline-item v-for="(item, i) in orderDatalist.endTrackDetailList" :key="i">
                <p class="time" v-text="item.date" />
                <p class="content" v-text="item.status" />
              </el-timeline-item>
            </el-timeline>
          </template>
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
import { orderDetailApi } from '@/api/halykOrder';
export default {
  name: 'OrderDetail',
  data() {
    return {
      direction: 'rtl',
      reverse: true,
      dialogVisible: false,
      orderDatalist: {
        beginTrackDetailList:[]
      },
      loading: false,
      modal2: false,
      result: [],
      resultInfo: {},
      activeNames:''
    };
  },
  mounted() {},
  methods: {
    handleClose() {
      this.dialogVisible = false;
    },
    getDetail(id) {
      this.loading = true;
      orderDetailApi({ id })
        .then((res) => {
          this.orderDatalist = res;
          this.loading = false;
        })
        .catch(() => {
          this.orderDatalist = null;
          this.loading = false;
        });
    },
  },
};
</script>

<style scoped lang="scss">
.title {
  font-size: 36px;
}
.demo-drawer__content {
  padding: 0 30px;
}
.demo-image__preview {
  width: 35px;
  height: auto;
  display: inline-block;
}
.logistics {
  align-items: center;
  padding: 10px 0px;
  .logistics_img {
    width: 45px;
    height: 45px;
    margin-right: 12px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .logistics_cent {
    span {
      display: block;
      font-size: 12px;
    }
  }
}

.trees-coadd {
  width: 100%;
  height: 400px;
  border-radius: 4px;
  overflow: hidden;
  .scollhide {
    width: 100%;
    height: 100%;
    overflow: auto;
    margin-left: 18px;
    padding: 10px 0 10px 0;
    box-sizing: border-box;
    .content {
      font-size: 12px;
    }

    .time {
      font-size: 12px;
      color: #2d8cf0;
    }
  }
}

.title {
  margin-bottom: 14px;
  color: #303133;
  font-weight: 500;
  font-size: 14px;
}

.description {
  &-term {
    display: table-cell;
    padding-bottom: 5px;
    line-height: 20px;
    width: 50%;
    font-size: 12px;
    color: #606266;
  }
  ::v-deep .el-divider--horizontal {
    margin: 12px 0 !important;
  }
}
</style>
